package com.yyx.app1.MedicationAssistant_function.Controls.MedicationAssistant_Activity_Control.Three_ListView;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.yyx.app1.Data.DataInit;

import java.util.List;

/**
 * Created by yuexing on 2015/8/27.
 */

public class Three_List_Adapter extends BaseAdapter {
    private Context context;
    private List<String> map;

    public Three_List_Adapter(Context context) {
        this.context = context;
    }

    public void findAll(String id)
    {
        map = new DataInit(context,false,"cxlin").getMedication_SQLiteOperation().getMedicationBySecond(id);
        if (map.size()==0)
        {
            map.add("暂无数据");
        }
        this.notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return map.size();
    }

    @Override
    public Object getItem(int position) {
        return map.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ThreeListView_ItemView it;
        if (convertView==null)
        {
            it = ThreeListView_ItemView_.build(context);
        }
        else
        {
            it = (ThreeListView_ItemView)convertView;
        }
        it.bind(new ItemDataType(position,map.get(position)));
        return it;
    }
}
